import java.awt.*;
import java.awt.event.MouseEvent;

public class DessinRectangle extends Dessin{
	private static final long serialVersionUID = 1L;
	
	Shape shape;
	
	public boolean contains(int x, int y)
	{
		if(shape == null || ! shape.getBounds().getSize().equals(getSize()))
		{
			shape = new Rectangle(0, 0, this.getWidth(), this.getHeight());
		}
		return shape.contains(x, y);
	}
	
	public void paint(Graphics g)
	{
		g.setColor(defaultColor);
		//g.fillRect(0, 0, this.getWidth(), this.getHeight());
		g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 20, 20);
	}

	public void mouseDragged(MouseEvent e) {
		DessinRectangle.this.setBounds(DessinRectangle.this.getX() + (e.getX() - xDebut), DessinRectangle.this.getY() + (e.getY() - yDebut), DessinRectangle.this.getWidth(), DessinRectangle.this.getHeight());
		
		repaint();
	}

	public void mousePressed(MouseEvent e) {
		xDebut = e.getX();
		yDebut = e.getY();
	}
}
